<?php
// require "../db.php"; 

//Log::::grabarLog("testeo");

/*
log

log_id     INT(10) UNSIGNED  (NULL)           NO      PRI     (NULL)   AUTO_INCREMENT  SELECT,INSERT,UPDATE,REFERENCES         
log_fecha  DATETIME          (NULL)           YES             (NULL)                   SELECT,INSERT,UPDATE,REFERENCES         
log_info   VARCHAR(255)      utf8_general_ci  YES             (NULL)                   SELECT,INSERT,UPDATE,REFERENCES         

*/

class Log
{
	
	public static $tabla = "z_logs_logins";
	public static $campo_fecha = "log_fecha";
	public static $campo_data = "log_info";
	public static $campo_data_adic = "info_adic";
	
	public static $debug = false;
	public static $grabar = true;
	
	
	public static function grabarLog($info)
	{
		$tabla = Log::$tabla;
		$fecha = Log::$campo_fecha;
		$data  = Log::$campo_data;		
	
		$sql = "INSERT INTO $tabla ($fecha, $data) VALUES (now(), '$info') ";
		if(Log::$grabar) 
        {
            $result = mysql_query($sql)  or trigger_error(mysql_error()); 
        }
        return 0;
		
    }
	
	public static function grabarLog2($info, $infoAdic)
	{
		$tabla = Log::$tabla;
		$fecha = Log::$campo_fecha;
		$data  = Log::$campo_data;		
		$data_adic  = Log::$campo_data_adic;		
	
		$sql = "INSERT INTO $tabla ($fecha, $data, $data_adic) VALUES (now(), '$info', '$infoAdic') ";
		if(Log::$grabar) 
        {
            $result = mysql_query($sql)  or trigger_error(mysql_error()); 
        }
        return 0;
		
    }
	
	
	
	public static function showTestConexion()
	{
		$sql = "SELECT * FROM ". Log::$tabla;	if(Log::$debug) die($sql);
		$result = mysql_query($sql)  or trigger_error(mysql_error()); 
		$row = mysql_fetch_array($result);

		echo "<pre>";
		print_r($row);
		echo "</pre>";
		
    }
	
}

?>